package com.sxc.loglib.ui;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.sxc.loglib.R;

import java.io.File;

/**
 * Created by sunxunchao on 2020/1/6
 */
public class LogAdapter extends AbsAdapter<File, LogAdapter.LogViewHolder> {

    private int position;

    public LogAdapter(Context context, int layoutId) {
        super(context, layoutId);
    }

    public void setSelectedItem(int position){
        this.position = position;
        notifyDataSetChanged();
    }

    @Override
    protected void initData(File data, LogViewHolder holder, int position) {
        if (this.position == position){
            holder.tv.setBackgroundColor(0xFF808080);
        }else {
            holder.tv.setBackgroundColor(Color.WHITE);
        }
        holder.tv.setText(data.getName());
    }

    @Override
    protected LogViewHolder newViewHolder(int position) {
        return new LogViewHolder();
    }

    static class LogViewHolder extends AbsViewHolder{

        private TextView tv;

        @Override
        public void initItemView(View containerView) {

            tv = containerView.findViewById(R.id.tv);
        }
    }
}
